import java.util.ArrayList;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;

/**
 * Class for the Databases
 * @author jcoston
 */
public class DatabaseInfo {

    private String databaseName;
    private ArrayList<ReswellTable> tables = new ArrayList<ReswellTable>();

	    /**
	     * Constructor to create a Database Object
	     * @param name String with the name of the database
	     * @param tables JsonArray with the tables
	     */
        public DatabaseInfo(String name, JsonArray tables) {
            databaseName = name;
            for (JsonElement elem : tables) {
            	String tname = elem.getAsJsonObject().get("tablename").getAsString();
            	JsonArray fields = elem.getAsJsonObject().get("fields").getAsJsonArray();
            	this.tables.add(new ReswellTable(tname, fields));
            }
           //array of table objects
        }

        /**
         * Return the name of the database
         */
        public String toString() {
            return databaseName;
        }
        
        public ArrayList<ReswellTable> getTables(){
        	return tables;
        }

}
